<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
 * Javascript 相关的一些助手函数
 */

if ( ! function_exists('show_alert'))
{
	function show_alert($prompt)
	{
		$alert = "";
		$alert.= '<script type="text/javascript" charset="utf-8">';
		$alert.="alert(\"$prompt\")";
		$alert.='</script>';
		echo $alert;
	}
}

if(! function_exists("show_alert_then_redirect"))
{
	function show_alert_then_redirect($prompt, $url)
	{
		$js = "";
		$js .= '<script type="text/Javascript">';
		$js .= 'function confirmRedirect()';
		$js .= '{';
		$js .= "if(confirm(\"$prompt\"))";
		$js .= 	"{";
		$js .= 		"window.location = \"$url\";";
		$js .= 	"}";
		$js .= "}";
		$js .= "</script>";
		echo $js;
	}
}

if(! function_exists("redirect_to_login"))
{ 
	function redirect_to_login()
	{
		$redirect = "";
		$redirect.='<script type="text/javascript" charset="utf-8">';
		$redirect.="top.window.location = '".site_url("login")."';";
		$redirect.='</script>';
		echo $redirect;
	}
}

if(! function_exists("utf8_echo"))
{
	function utf8_echo($msg)
	{
		header("Content-Type:text/html;charset=utf-8");
		echo $msg;
	}
	
}

?>